package domain.controllers;


import domain.Entity.EntityUsuario;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import managers.InformeManager;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import org.springframework.web.servlet.view.RedirectView;



/**
 *
 * @author jorge
 */
public class guardarController implements Controller{

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
       
        ModelAndView mav = new ModelAndView();
       HttpSession session = request.getSession();
       EntityUsuario eu = (EntityUsuario) session.getAttribute("usuario");
        if(eu == null){
            mav.setView(new RedirectView("login.htm"));
            return mav;
        }else{
    
        InformeManager im = InformeManager.getInstance();
        
        im.addInforme(session);
        
        mav.setView(new RedirectView("mostrarInformes.htm"));
        return mav;
        }
    }

}
